package cn.iocoder.yudao.module.system.controller.admin.mini.group.goods.dal.mysql.groupgoods;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.system.controller.admin.mini.group.goods.controller.admin.groupgoods.vo.GroupGoodsExportReqVO;
import cn.iocoder.yudao.module.system.controller.admin.mini.group.goods.controller.admin.groupgoods.vo.GroupGoodsPageReqVO;
import cn.iocoder.yudao.module.system.controller.admin.mini.group.goods.dal.dataobject.groupgoods.GroupGoodsDO;
import org.apache.ibatis.annotations.Mapper;

/**
 * 拼团商品 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface GroupGoodsMapper extends BaseMapperX<GroupGoodsDO> {

    default PageResult<GroupGoodsDO> selectPage(GroupGoodsPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<GroupGoodsDO>()
                .betweenIfPresent(GroupGoodsDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(GroupGoodsDO::getGoodsId, reqVO.getGoodsId())
                .eqIfPresent(GroupGoodsDO::getGoodsInfo, reqVO.getGoodsInfo())
                .likeIfPresent(GroupGoodsDO::getName, reqVO.getName())
                .eqIfPresent(GroupGoodsDO::getGroupId, reqVO.getGroupId())
                .betweenIfPresent(GroupGoodsDO::getStartTime, reqVO.getStartTime())
                .betweenIfPresent(GroupGoodsDO::getEntTime, reqVO.getEntTime())
                .eqIfPresent(GroupGoodsDO::getActNum, reqVO.getActNum())
                .eqIfPresent(GroupGoodsDO::getSoldNum, reqVO.getSoldNum())
                .eqIfPresent(GroupGoodsDO::getStatus, reqVO.getStatus())
                .eqIfPresent(GroupGoodsDO::getGroupPerson, reqVO.getGroupPerson())
                .eqIfPresent(GroupGoodsDO::getGroupHour, reqVO.getGroupHour())
                .eqIfPresent(GroupGoodsDO::getIsAlone, reqVO.getIsAlone())
                .eqIfPresent(GroupGoodsDO::getIsGroup, reqVO.getIsGroup())
                .orderByDesc(GroupGoodsDO::getId));
    }

    default List<GroupGoodsDO> selectList(GroupGoodsExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<GroupGoodsDO>()
                .betweenIfPresent(GroupGoodsDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(GroupGoodsDO::getGoodsId, reqVO.getGoodsId())
                .eqIfPresent(GroupGoodsDO::getGoodsInfo, reqVO.getGoodsInfo())
                .likeIfPresent(GroupGoodsDO::getName, reqVO.getName())
                .eqIfPresent(GroupGoodsDO::getGroupId, reqVO.getGroupId())
                .betweenIfPresent(GroupGoodsDO::getStartTime, reqVO.getStartTime())
                .betweenIfPresent(GroupGoodsDO::getEntTime, reqVO.getEntTime())
                .eqIfPresent(GroupGoodsDO::getActNum, reqVO.getActNum())
                .eqIfPresent(GroupGoodsDO::getSoldNum, reqVO.getSoldNum())
                .eqIfPresent(GroupGoodsDO::getStatus, reqVO.getStatus())
                .eqIfPresent(GroupGoodsDO::getGroupPerson, reqVO.getGroupPerson())
                .eqIfPresent(GroupGoodsDO::getGroupHour, reqVO.getGroupHour())
                .eqIfPresent(GroupGoodsDO::getIsAlone, reqVO.getIsAlone())
                .eqIfPresent(GroupGoodsDO::getIsGroup, reqVO.getIsGroup())
                .orderByDesc(GroupGoodsDO::getId));
    }

}
